
#include <8052.h>

#include "misc.h"
#include "daad.h"

//DA展示
void da_show()
{
    //重置段选位选,关闭其它无关的组件
    P2_6 = P2_7 = 0;

    P3_2 = 0; //CSDA片选

    P3_6 = 0; //WR写入开关
    P0 = 0;
    while (1)
    {
        //未管溢出，溢出自动从0开始
        unsigned char p0value = P0;
        P0 = p0value + 1;
        delay(10);
    }
}

//ad收集的数据转到da中进行展示
void ad_da_show()
{
    //重置段选位选,关闭其它无关的组件
    P2_6 = P2_7 = 0;

    P2_7 = 1; //开启位选:因为主板把CSAD接到位选锁存上面了
    P0_7 = 0; //对应把CSAD打开
    P2_7 = 0;

    P3_7 = 0; //RD
    P3_6 = 0; //WR 写入开关
    while (1)
    {
        P3_6 = 1;
        P3_6 = 0;
        P3_6 = 1;
        delay(20);

        //由DA显示到发光二极管
        P3_2 = 0; //CSDA片选
        P3_6 = 0;
        char p1value = P1;
        P0 = p1value; 
        delay(20);
    }
}